<template>
  <view class="w-screen h-screen flex items-center">
    <wd-button @click="logincode" type="primary" custom-style="width: 100vw; height: 40px;"
      >一键登陆</wd-button
    >
  </view>
</template>

<script setup>
import { wxlogin } from '@/utils/api'
// 一键登陆
const logincode = () => {
  uni.login({
    success(res) {
      console.log(res.code)
      wxlogin(res.code).then((res) => {
        console.log(res)
        uni.setStorageSync('accessToken', res.data.access_token)
        uni.showToast({
          title: '登陆成功',
          icon: 'success',
          success: () => {
            setTimeout(() => {
              uni.switchTab({
                url: '/pages/index/index',
              })
            }, 1000)
          },
        })
      })
    },
  })
}
</script>

<style scoped></style>
